<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>研发部API接口测试</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>
<style>
    .btn {
        display: block;
        width: 250px;
        height: 40px;
        line-height: 40px;
        color: #fff;
        text-align: center;
        background-color: #1c85c2;
        text-decoration: none;
        margin-top: 30px;
    }

    input {
        width: 250px;
        height: 25px;
    }

    textarea {
        width: 250px;
        height: 200px;
    }
</style>
<body>
<h1>Api URL</h1>
<input type="text" class="url" value="http://localhost:90/index.php"/>
<h1>model</h1>
<input type="text" class="model" value="member"/>
<h1>action</h1>
<input type="text" class="action" value="getMemberListById"/>
<h1>其他参数(json格式)</h1>
<textarea class="params"></textarea>
<a href="javascript:void(0)" class="btn">请求接口</a>
</body>
<script>
    $(function(){
        $(".btn").click(function(){
            var _url=$(".url").val();
            var model=$(".model").val();
            var action=$(".action").val();
            var params_str='{'+$(".params").val()+'}';
            var params=eval("("+params_str+")");
            var postdata="";
            debugger;
            if(params!=""){
                postdata={"model":model,"action":action};
                postdata=Object.assign(params,postdata);
            }else{
                postdata={"model":model,"action":action};
            }
            $.ajax({
                url:_url,
                type:"post",
                data:postdata,
                success:function(res){
                    console.log(res);
                }
            })
        });
    })
</script>
</html>